Skip to content

feat: WIP - upgrade resource and did modules to v0.50.x #876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 51 commits into
base: akhil/v0.50_bump
Choose a base branch
from

Conversation

PrathyushaLakkireddy
Copy link
Collaborator

No description provided.

@PrathyushaLakkireddy PrathyushaLakkireddy changed the title WIP: upgrade resource module to v0.50.x WIP: upgrade resource and did modules to v0.50.x Apr 17, 2025
@Eengineer1 Eengineer1 self-requested a review April 22, 2025 17:43
@Eengineer1 Eengineer1 changed the title WIP: upgrade resource and did modules to v0.50.x feat: WIP - upgrade resource and did modules to v0.50.x Apr 22, 2025

// Apply changes. We create a new version on deactivation to track deactivation time
err = k.AddNewDidDocVersion(&ctx, &didDoc)
err = k.AddNewDidDocVersion(&goCtx, &didDoc)
if err != nil {
return nil, types.ErrInternal.Wrapf(err.Error())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this non-constant string check necessary? If so, update to the necessary syntax / format.

Comment on lines 7 to 12
var (
KeyCreateDid = []byte("KeyCreateDid")
KeyUpdateDid = []byte("UpdateDid")
KeyDeactivateDid = []byte("DeactivateDid")
KeyBurnFactor = []byte("BurnFactor")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var (
KeyCreateDid = []byte("KeyCreateDid")
KeyUpdateDid = []byte("UpdateDid")
KeyDeactivateDid = []byte("DeactivateDid")
KeyBurnFactor = []byte("BurnFactor")
)
var (
KeyCreateDid = []byte("FeeParamsCreateDid")
KeyUpdateDid = []byte("FeeParamsUpdateDid")
KeyDeactivateDid = []byte("FeeParamsDeactivateDid")
KeyBurnFactor = []byte("FeeParamsDidBurnFactor")
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the notation consistent as suggested above 👍.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we restoring unit tests soon?

Let's validate the changes are functional, before progressing any further.

feeParams := k.GetParams(ctx)
feeParams, err := k.GetParams(ctx)
if err != nil {
panic(fmt.Sprintln("Cannot get fee params: %s", err.Error()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, as denoted: Let's either replace with a valid syntactical format or skip the lint rule.

if req == nil {
return nil, status.Error(codes.InvalidArgument, "invalid request")
}

ctx := sdk.UnwrapSDKContext(c)
// ctx := sdk.UnwrapSDKContext(c)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's safely remove this.

Comment on lines 20 to 27
// Default parameter values
// const (
// DefaultCreateResourceImageFee = 100000 // Example value
// DefaultCreateResourceJSONFee = 75000 // Example value
// DefaultCreateResourceDefaultFee = 50000 // Example value
// DefaultBurnFactor = "0.5" // Example value
// BaseMinimalDenom = "ncheq" // Example value
// )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's safely remove this as it's already defined in genesis.go.

Comment on lines 7 to 12
var (
KeyResourceImageFee = []byte("KeyResourceImageFee")
KeyCreateResourceJSONFee = []byte("KeyCreateResourceJSONFee")
KeyCreateResourceKeyFee = []byte("KeyCreateResourceKeyFee")
KeyBurnFactor = []byte("KeyBurnFactor")
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
var (
KeyResourceImageFee = []byte("KeyResourceImageFee")
KeyCreateResourceJSONFee = []byte("KeyCreateResourceJSONFee")
KeyCreateResourceKeyFee = []byte("KeyCreateResourceKeyFee")
KeyBurnFactor = []byte("KeyBurnFactor")
)
var (
KeyResourceImageFee = []byte("FeeParamsResourceImage")
KeyCreateResourceJSONFee = []byte("FeeParamsResourceJSON")
KeyCreateResourceKeyFee = []byte("FeeParamsResourceKeyFee")
KeyBurnFactor = []byte("FeeParamsResourceBurnFactor")
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make the notation consistent as suggested above 👍.

@Eengineer1
Copy link
Contributor

Let's focus on resolving the build errors, before moving on with unit, integration + upgrade tests in that order.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is the content removed but not the file?

I do see you've added it to .gitignore. What's the modified approach here?

Comment on lines +97 to +102
func (k Keeper) SetDidDocVersion(ctx context.Context, value *types.DidDocWithMetadata, override bool) error {
hasdidVersion, err := k.HasDidDocVersion(ctx, value.DidDoc.Id, value.Metadata.VersionId)
if err != nil {
return err
}
if !override && hasdidVersion {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if override takes precedence over checking whether there's a DID doc version or not?

In this scenario, HasDidDocVersion will not be invoked at all, if override is true. That's not reflected in this refactored block of code.

PS: If A && B {}, B will be checked if A resolves to true. Otherwise, B won't be invoked / evaluated at all as the whole statement resolves to false if A is false.

Comment on lines +162 to +164
if err := msg.ValidateBasic(); err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't basic validation performed by the message server as is or has that significantly changed?

If yes for the former, do we need this extra validation step? My guess is we don't.

denoms := msg.Amount.Denoms()
if len(denoms) != 0 {
err := ValidateDenom(denoms, bondDenom)
if err != nil {
return nil, err
}
}
err := msg.ValidateBasic()
err = msg.ValidateBasic()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to re-run basic validation here as well as at the beginning?

Comment on lines +11 to +13
if err := msg.ValidateBasic(); err != nil {
return nil, err
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar note here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants